package cn.tedu.stage2.file;

import java.io.File;

public class DeleteFileDemo {
    public static void main(String[] args) {
        File file = new File("/test1.txt");
        if(file.exists()){
            file.delete();
            System.out.println("该文件已删除！");
        }else{
            System.out.println("该文件不存在！");
        }
        // 删除当前目录中的test1.txt  -  test100.txt
        for (int i=1;i<=100;i++){
            File f = new File("test" + i + ".txt");
            if (f.exists()){
                f.delete();
                System.out.println("该文件已删除！");
            } else {
                System.out.println("该文件不存在！");
            }
        }
    }
}
